package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Movement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 动态详情表
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MovementVo implements Serializable {


    private String id; //主键id
    private Integer userId;
    private String textContent; //文字
    private Integer state; //审核状态，1为待审核，2为自动审核通过，3为待人工审核，4为人工审核拒绝，5为人工审核通过，6为自动审核拒绝
    private Integer likeCount; //点赞数
    private Integer commentCount; //评论数

    private Integer createDate; //发布时间
    private List<String> imageContent; //图片列表

    private String nickname; //作者昵称
    private String avatar; //作者头像

    public static MovementVo init(UserInfo userInfo, Movement movement) {
        MovementVo vo = new MovementVo();
        BeanUtils.copyProperties(movement,vo);

        vo.setId(String.valueOf(movement.getId()));
        vo.setUserId(Integer.valueOf(String.valueOf(movement.getUserId())));
        vo.setCreateDate(Integer.valueOf(String.valueOf(movement.getCreated())));
        vo.setImageContent(movement.getMedias());
        vo.setNickname(userInfo.getNickname());
        vo.setAvatar(userInfo.getAvatar());
        return vo;
    }

}